<?php
/**
 *
 *
 */
class Yz_Model_Field_OneToMany
    extends Yz_Model_Field_ReferenceList
{

    protected $keyName;

    /** Required config property 'foreignKey' which is the name of
     *      the referenced property (! - not a db field) in the referenced model
     *  @param Yz_Model_Interface|null $model => null for 'compatible' __construct
     */
    public function __construct( $config=null )
    {
        debug();
        parent::__construct( $config );
        $keyName = $this->fetchConfig('foreignKey');
        if (! $keyName)
            throw AttributeError::_new_(array('attr' => 'foreignKey'));
        assert('$model[$keyName] instanceof Yz_Model_Field_ForeignKey');
        $this->keyName = $keyName;
    }

    public function getKeyName()
    {
        return $this->keyName;
    }

}
